<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta charset="utf-8"/>
    <title>首页</title>
</head>
<body>
<input type="button" value="发送" onclick="WEB_SOCKET_UTILS.send('12313')">
<div id="title">

</div>
<!-- js部分 -->
<script src="/js/jquery-3.2.1.min.js"></script>
<script src="/js/web_socket_utils.js"></script>
<script>
    WEB_SOCKET_UTILS.initWebSocket("ws://localhost/websocket/");

    /*var ws;
    openWebSocket();
    function openWebSocket(){
        if ("WebSocket" in window) {
            //如果已经有连接，则断开并重新连接
            if (ws != null) {
                ws.close();
                ws = null;
            }
            // 创建一个 websocket　　　　　　　
            var UUID = 123;
            ws = new WebSocket("ws://localhost/websocket/"+UUID);
            ws.onopen = function () {
                console.log('WebSocket连接已建立')
            };
            //获得消息事件
            ws.onmessage = function (evt) {
                $("#title").html('<p>接收：'+evt.data+'</p>');
            };
            ws.onclose = function () {
                console.log('WebSocket连接已断开')
            };
        } else {
            // 浏览器不支持 WebSocket
            console.log('您的浏览器不支持 WebSocket!');
        }
    }
    function send(){
        ws.send(JSON.stringify({msg:'123123'}));
    }*/

</script>
</body>
</html>